1. Field of the Invention
The present invention relates to an image processing apparatus, an image processing method, and a program, and more particularly, to an image processing apparatus, an image processing method, and a program appropriately used for performing edge-preserving smoothing and gray-scale correction on an image.
2. Description of the Related Art
An edge-preserving smoothing process is used as one of image processing techniques according to the related art. The edge-preserving smoothing process refers to nonlinear filter processing performed to smooth gray scales while a pronounced luminance-level difference in the boundary or the like of objects in an image remains. The edge-preserving smoothing process was used in noise reduction processing in the past, since a minute luminance variation is removed while the contour of an object having an influence on visibility is preserved through the edge-preserving smoothing process (for example, see A. Lev, S. W. Zucker, A. Rosenfeld, “Iterative enhancement of noise images”, IEEE Trans. Systems, Man, and Cybernetics, Vol. SMC-7, 1977; D. C. C. Wang, A. H. Vagnucci, C. C. Li, “Gradient inverse weighted smoothing scheme and the evaluation of its performance”, CVGIP, Vol. 15, pp. 167-181, 1981; M. Nagao, T. Matsuyama, “Edge preserving smoothing”, CGIP, Vol. 9, pp. 394-407, 1978; and D. T. Kuan, A. A. Sawchuk, T. C. Strand, P. Chavel, “Adaptive noise smoothing filter for images with signal-dependent noise”, IEEE Trans. Pattern Analysis and Machine Intelligence, Vol. Pami-7, No. 2 1985).
Moreover, the edge-preserving smoothing process is also used in a gray-scale correction process in which luminance differences of other components other than a detail component such as texture are compressed utilizing a property capable of separating the minute luminance variation in the texture within an object from the pronounced luminance-level difference of the contour of an object without changing the detail component (for example, see F. Durand, J. Dorsey, “Fast bilateral filtering for the display of high-dynamic-range images”, Proc. Of ACM SIGGRAPH 2002, 2002; and S. N. Pattanaik, H. Yee, “Adaptive gain control for high dynamic range image display”, Proc. of Spring Conference in Computer Graphics 2002, 2002).
When the edge-preserving smoothing process is performed, the capability of the gray-scale correction process performed using the edge-preserving smoothing process can be improved by enlarging the area (hereafter, also referred to as a smoothing area) of the peripheral pixels used in the vicinity of one pixel. On the other hand, when the smoothing area is enlarged, the calculation amount is increased. Accordingly, there has been suggested a method of performing the edge-preserving smoothing process with a smaller calculation amount (for example, see Japanese Unexamined Patent Application Publication No. 2009-177558). Hereinafter, the overview of the edge-preserving smoothing process disclosed in Japanese Unexamined Patent Application Publication No. 2009-177558 will be described.
In the edge-preserving smoothing process disclosed in Japanese Unexamined Patent Application Publication No. 2009-177558, a luminance image corresponding to one frame is divided into a plurality of spatial blocks (areas) in a space direction and each of the spatial blocks is further divided into a plurality of luminance blocks in a luminance direction. Then, the number of pixels belonging to each of the luminance blocks of each spatial block is counted and a block histogram is generated. In addition, the total sum of the luminance values of the pixels belonging to each luminance block is calculated as a block integral value for each spatial block. A general luminance value Ll obtained by smoothing a luminance values L of the pixels of the luminance image is calculated by Expression (1) below.
                    [                  Expression          ⁢                                          ⁢          1                ]                                                                      Ll          ⁡                      (                          i              ,              j              ,              L                        )                          =                ⁢                                                            [                                  ϕ                  *                  S                                ]                            ⁢                              (                                  i                  ,                  j                  ,                  L                                )                                                                    [                                  ϕ                  *                  H                                ]                            ⁢                              (                                  i                  ,                  j                  ,                  L                                )                                              =                    ⁢                                    ∫                                                                    ϕ                    ⁡                                          (                                              L                        -                        λ                                            )                                                        ·                                      S                    ⁡                                          (                                              i                        ,                        j                        ,                        λ                                            )                                                                      ⁢                                  ⅆ                  λ                                                                    ∫                                                                    ϕ                    ⁡                                          (                                              L                        -                        λ                                            )                                                        ·                                      H                    ⁡                                          (                                              i                        ,                        j                        ,                        λ                                            )                                                                      ⁢                                  ⅆ                  λ                                                                                        (        1        )            
In Expression (1), i and j are an index indicating the position of a spatial block BK(i, j) located at an i-th position from the upper side of a luminance image and at a j-th position from the left side of the luminance image. H(i, j, λ) is a function (hereinafter, referred to as a block luminance distribution function) representing a distribution (that is, a frequency distribution of the luminance value λ in the spatial block BK(i, j)) of the number of pixels with the luminance value λ among pixels of the spatial block BK(i, j). S(i, j, λ) is a function (hereinafter, referred to as a block integral value distribution function) representing a distribution of a total sum (block integral value) of luminance values of the pixels with luminance value λ among the pixels of the spatial block BK(i, j). φ(x) is a weight function for smoothing. For example, a Gauss function of distribution Va of Expression (2) below is used.
                    [                  Expression          ⁢                                          ⁢          2                ]                                                                      ϕ          ⁡                      (            x            )                          =                              1                                          2                ⁢                π                ⁢                                                                  ⁢                Va                                              ⁢                      exp            (                          -                                                x                  2                                Va                                      )                                              (        2        )            
Accordingly, the weight function φ (L−λ) of Expression (1) is increased as λ gets closer to a luminance value L, and is decreased as λ gets farther from the luminance value L.
φ*H indicates convolution calculation in a luminance direction between the weight function φ and the block luminance distribution function H. φ*S indicates a convolution calculation of the weight function φ and the block integral value distribution function S in the luminance direction.
By Expression (1), the luminance values of pixels are weighted so that the weight is increased as the pixels gets closer to the luminance value L of a noticed pixel (hereafter, referred to as a processing target pixel) to be processed among the pixels belonging to a spatial block BK(i, j), and a weighted average value of the luminance values in the spatial block BK(i, j) is calculated as a general luminance value Ll of processing target pixels. As a result, since an area such as a flat part of the luminance image, where the pixels with a value close to the luminance value are continuous, are smoothed, and the pronounced luminance-level difference of the edge portion or the like is maintained.